﻿<UserControl x:Class="Chapters.Chapter14.KeyboardNavigationExample"
			 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
			 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
			 xmlns:clr="clr-namespace:System;assembly=mscorlib">
	<UserControl.Resources>
		<ObjectDataProvider x:Key="NavigationModeEnum"
							ObjectType="{x:Type clr:Enum}"
							MethodName="GetValues">
			<ObjectDataProvider.MethodParameters>
				<x:Type TypeName="KeyboardNavigationMode" />
			</ObjectDataProvider.MethodParameters>
		</ObjectDataProvider>
	</UserControl.Resources>
	<DockPanel>
		<TextBlock x:Name="_focusedElement"
				   DockPanel.Dock="Top" />

		<ComboBox x:Name="NavigationEnum" DockPanel.Dock="Top"
				  Margin="0,20,0,0" ItemsSource="{Binding Source={StaticResource NavigationModeEnum}}"
				  SelectedIndex="0">
		</ComboBox>

			<Grid Height="90"
			  Width="200"
			  KeyboardNavigation.TabNavigation="{Binding SelectedItem, ElementName=NavigationEnum}">
			<Grid.RowDefinitions>
				<RowDefinition />
				<RowDefinition />
				<RowDefinition />
			</Grid.RowDefinitions>

			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="Auto" />
				<ColumnDefinition />
			</Grid.ColumnDefinitions>

			<TextBlock Text="Username"
					   Grid.Row="0"
					   Grid.Column="0"
					   HorizontalAlignment="Right"
					   VerticalAlignment="Center"
					   Margin="0,0,8,0" />
			<TextBlock Text="Password"
					   Grid.Row="1"
					   Grid.Column="0"
					   HorizontalAlignment="Right"
					   VerticalAlignment="Center"
					   Margin="0,0,8,0" />

			<TextBox Grid.Row="0"
					 Grid.Column="1"
					 KeyboardNavigation.TabIndex="2" />
			<TextBox Grid.Row="1"
					 Grid.Column="1"
					 KeyboardNavigation.TabIndex="3" />

			<StackPanel Grid.Row="2"
						Grid.Column="1"
						Orientation="Horizontal"
						HorizontalAlignment="Right">
				<Button Content="Cancel"
						Margin="0,0,8,0"
						KeyboardNavigation.TabIndex="1" />
				<Button Content="Submit" KeyboardNavigation.TabIndex="0"/>
			</StackPanel>
		</Grid>

	</DockPanel>
</UserControl>
